From 084df3b9f77bdc13b470e9feafc463c96dc9fb85 Mon Sep 17 00:00:00 2001 From: "kfraser@localhost.localdomain" Date: Wed, 20 Jun 2007 16:52:01 +0100 Subject: [PATCH] kernel command line extension In order to allow appending to the dom0 command line even with boot loaders that only allow editing the kernel (i.e. Xen in our case) command line, support a '--' separator option. Signed-off-by: Jan Beulich Signed-off-by: Keir Fraser --- xen/arch/x86/setup.c | 32 ++++++++++++++++++++++++++------ 1 file changed, 26 insertions(+), 6 deletions(-) diff --git a/xen/arch/x86/setup.c b/xen/arch/x86/setup.c index 23e216ac44..c630cb242f 100644 --- a/xen/arch/x86/setup.c +++ b/xen/arch/x86/setup.c @@ -405,7 +405,7 @@ void init_done(void) void __init __start_xen(unsigned long mbi_p) { char *memmap_type = NULL; - char __cmdline[] = "", *cmdline = __cmdline; + char __cmdline[] = "", *cmdline = __cmdline, *kextra; unsigned long _initrd_start = 0, _initrd_len = 0; unsigned int initrdidx = 1; char *_policy_start = NULL; @@ -426,6 +426,17 @@ void __init __start_xen(unsigned long mbi_p) /* Parse the command-line options. */ if ( (mbi->flags & MBI_CMDLINE) && (mbi->cmdline != 0) ) cmdline = __va(mbi->cmdline); + if ( (kextra = strstr(cmdline, " -- ")) != NULL ) + { + /* + * Options after ' -- ' separator belong to dom0. + * 1. Orphan dom0's options from Xen's command line. + * 2. Skip all but final leading space from dom0's options. + */ + *kextra = '\0'; + kextra += 3; + while ( kextra[1] == ' ' ) kextra++; + } cmdline_parse(cmdline); parse_video_info(); @@ -1009,18 +1020,27 @@ void __init __start_xen(unsigned long mbi_p) /* Grab the DOM0 command line. */ cmdline = (char *)(mod[0].string ? __va(mod[0].string) : NULL); - if ( cmdline != NULL ) + if ( (cmdline != NULL) || (kextra != NULL) ) { static char dom0_cmdline[MAX_GUEST_CMDLINE]; - /* Skip past the image name and copy to a local buffer. */ - while ( *cmdline == ' ' ) cmdline++; - if ( (cmdline = strchr(cmdline, ' ')) != NULL ) + dom0_cmdline[0] = '\0'; + + if ( cmdline != NULL ) { + /* Skip past the image name and copy to a local buffer. */ while ( *cmdline == ' ' ) cmdline++; - safe_strcpy(dom0_cmdline, cmdline); + if ( (cmdline = strchr(cmdline, ' ')) != NULL ) + { + while ( *cmdline == ' ' ) cmdline++; + safe_strcpy(dom0_cmdline, cmdline); + } } + if ( kextra != NULL ) + /* kextra always includes exactly one leading space. */ + safe_strcat(dom0_cmdline, kextra); + /* Append any extra parameters. */ if ( skip_ioapic_setup && !strstr(dom0_cmdline, "noapic") ) safe_strcat(dom0_cmdline, " noapic"); -- 2.30.2